﻿<Window
  x:Class="SanctusSoftware.Music.ChordSheetEditor.Wpf.FormatWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:SanctusSoftware.Music.ChordSheetEditor.Wpf"
  Title="Format"
  Height="292"
  Width="385"
  WindowStartupLocation="CenterScreen"
  WindowStyle="SingleBorderWindow"
  ResizeMode="NoResize">
  <Window.Resources>
    <!--<local:WdColorStringConverter
      x:Key="_WdColorStringConverter" />
    <local:WdColorColorConverter
      x:Key="_WdColorColorConverter" />-->
  </Window.Resources>
  <Grid
    Background="#F0F0F0">
    <Grid.RowDefinitions>
      <RowDefinition
        Height="*" />
      <RowDefinition
        Height="Auto" />
    </Grid.RowDefinitions>
    <Border
      Grid.Row="0"
      Margin="7"
      Padding="7"
      Background="White"
      BorderBrush="DarkGray"
      BorderThickness="1">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition
            Width="Auto" />
          <ColumnDefinition
            Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition
            Height="Auto" />
          <RowDefinition
            Height="Auto" />
          <RowDefinition
            Height="Auto" />
          <RowDefinition
            Height="Auto" />
          <RowDefinition
            Height="Auto" />
          <RowDefinition
            Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.Resources>
          <Style
            TargetType="{x:Type CheckBox}">
            <Setter
              Property="Margin"
              Value="7 7 0 0" />
          </Style>
        </Grid.Resources>

        <!--Font Name-->
        <CheckBox
          Grid.Column="0"
          Grid.Row="0"
          IsChecked="{Binding SetFontName,UpdateSourceTrigger=PropertyChanged}">Set Font Name</CheckBox>
        <ComboBox
          Grid.Column="1"
          Grid.Row="0"
          Margin="7 7 7 0"
          ItemsSource="{Binding FontFamilies, Mode=OneWay}"
          Text="{Binding FontNameValue,UpdateSourceTrigger=PropertyChanged}">
          <ComboBox.ItemsPanel>

            <ItemsPanelTemplate>

              <VirtualizingStackPanel />

            </ItemsPanelTemplate>

          </ComboBox.ItemsPanel>

          <ComboBox.ItemTemplate>

            <DataTemplate>

              <TextBlock
                Text="{Binding}"
                FontFamily="{Binding}"
                FontSize="15"
                Height="20" />

            </DataTemplate>

          </ComboBox.ItemTemplate>
        </ComboBox>

        <!--Font Size-->
        <CheckBox
          Grid.Column="0"
          Grid.Row="1"
          IsChecked="{Binding SetFontSize,UpdateSourceTrigger=PropertyChanged}">Set Font Size</CheckBox>
        <ComboBox
          x:Name="_FontSizeComboBox"
          Grid.Column="1"
          Grid.Row="1"
          Margin="7 7 7 0"
          Width="60"
          HorizontalAlignment="Left"
          ItemsSource="{Binding FontSizes}"
          SelectedItem="{Binding FontSizeValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
          IsEditable="True"  PreviewTextInput="_FontSizeComboBox_PreviewTextInput" LostFocus="_FontSizeComboBox_LostFocus"   />

        <!--Font Color-->
        <CheckBox
          Grid.Column="0"
          Grid.Row="2"
          IsChecked="{Binding SetFontColor,UpdateSourceTrigger=PropertyChanged}">Set Font Color</CheckBox>
        <ComboBox
          Grid.Column="1"
          Grid.Row="2"
          Margin="7 7 7 0"
          ItemsSource="{Binding AvailableColors, Mode=OneWay}"
          SelectedItem="{Binding FontColorValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
          SelectionChanged="ComboBox_SelectionChanged">
          <ComboBox.ItemTemplate>
            <DataTemplate>
              <Grid
                HorizontalAlignment="Stretch">
                <Grid.ColumnDefinitions>
                  <ColumnDefinition
                    Width="*" />
                  <ColumnDefinition
                    Width="Auto" />
                </Grid.ColumnDefinitions>
                <Rectangle
                  Grid.Column="0"
                  Stroke="Gray"
                  StrokeThickness="0.5"
                  RadiusX="1"
                  RadiusY="1"
                  HorizontalAlignment="Right"
                  VerticalAlignment="Center"
                  Height="13"
                  Width="15"
                  Margin="7 0 7 0">
                  <Rectangle.Fill>
                    <SolidColorBrush
                      Color="{Binding Path=Color}" />
                  </Rectangle.Fill>
                </Rectangle>
                <TextBlock
                  Grid.Column="1"
                  Text="{Binding Path=Name}"
                  HorizontalAlignment="Stretch" />


              </Grid>
            </DataTemplate>
          </ComboBox.ItemTemplate>
        </ComboBox>

        <!--Bold-->
        <CheckBox
          Grid.Column="0"
          Grid.Row="3"
          IsChecked="{Binding SetBold,UpdateSourceTrigger=PropertyChanged}">Set Bold</CheckBox>
        <ToggleButton
          Grid.Column="1"
          Grid.Row="3"
          Margin="7 7 0 0"
          Height="24"
          Width="24"
          HorizontalAlignment="Left"
          IsChecked="{Binding BoldValue,UpdateSourceTrigger=PropertyChanged}">B</ToggleButton>

        <!--Italic-->
        <CheckBox
          Grid.Column="0"
          Grid.Row="4"
          IsChecked="{Binding SetItalic,UpdateSourceTrigger=PropertyChanged}">Set Italic</CheckBox>
        <ToggleButton
          Grid.Column="1"
          Grid.Row="4"
          Margin="7 7 0 0"
          Height="24"
          Width="24"
          HorizontalAlignment="Left"
          IsChecked="{Binding ItalicValue,UpdateSourceTrigger=PropertyChanged}">I</ToggleButton>

        <!--Underline-->
        <CheckBox
          Grid.Column="0"
          Grid.Row="5"
          IsChecked="{Binding SetUnderline,UpdateSourceTrigger=PropertyChanged}">Set Underline</CheckBox>
        <ToggleButton
          Grid.Column="1"
          Grid.Row="5"
          Margin="7 7 0 0"
          Height="24"
          Width="24"
          HorizontalAlignment="Left"
          IsChecked="{Binding UnderlineValue,UpdateSourceTrigger=PropertyChanged}">U</ToggleButton>

      </Grid>
    </Border>
    <StackPanel
      Grid.Row="1"
      Orientation="Horizontal"
      HorizontalAlignment="Right"
      Margin="7 0 14 7">
      <StackPanel.Resources>
        <Style
          TargetType="{x:Type Button}">
          <Setter
            Property="Width"
            Value="75" />
          <Setter
            Property="Height"
            Value="24" />
        </Style>
      </StackPanel.Resources>
      <Button
        x:Name="_OKButton"
        IsDefault="True"
        IsEnabled="{Binding IsOKButtonEnabled, Mode=OneWay}"
        Click="_OKButton_Click">OK</Button>
      <Button
        Margin="7 0 0 0"
        x:Name="_CancelButton"
        IsCancel="True"
        Click="_CancelButton_Click">Cancel</Button>
    </StackPanel>
  </Grid>


</Window>
